home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3006
/
3006.xpi
/
chrome
/
dwhelper.jar
/
content
/
mp3tunes
/
mp3tunes.xml
< prev
next >
Wrap
Extensible Markup Language
|
2010-01-15
|
16KB
|
578 lines
<?xml version="1.0"?>
<!-- *****************************************************************************
* Copyright (c) 2006-2007 Michel Gutierrez. All Rights Reserved.
****************************************************************************** -->
<!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="MP3TunesConfig" extends="../widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox flex="1">
<spacer flex="1"/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row anonid="xStatusRow" hidden="true">
<label value="&mp3tunes.pref.last-check;"/>
<description anonid="xStatus" class="feature-descr" style="max-height: 20px; overflow: auto;"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.username;"/>
<textbox anonid="xUsername"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.password;"/>
<DHPassword anonid="xPassword"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.phonenumber;"/>
<hbox align="center">
<textbox anonid="xPhonenumber"/>
<label value="&mp3tunes.pref.phonenumber-sample;" style="font-style: italic;"/>
</hbox>
</row>
<row>
<spacer/>
<description class="feature-descr">&mp3tunes.pref.phonenumber.description;</description>
</row>
<row>
<spacer/>
<hbox>
<spacer flex="1"/>
<button label="&label.privacy-policy;" oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.privacyPolicy()"/>
</hbox>
</row>
<row>
<spacer/>
<hbox align="center">
<spacer flex="1"/>
<label value="&mp3tunes.pref.on-send-mobile;"/>
<menulist anonid="xOnMobile">
<menupopup>
<menuitem label="&mp3tunes.pref.on-send.video;" value="video"/>
<menuitem label="&mp3tunes.pref.on-send.audio;" value="audio"/>
<menuitem label="&mp3tunes.pref.on-send.ask;" value="ask"/>
</menupopup>
</menulist>
</hbox>
</row>
<row>
<spacer/>
<hbox align="center">
<spacer flex="1"/>
<label value="&mp3tunes.pref.on-send-locker;"/>
<menulist anonid="xOnLocker">
<menupopup>
<menuitem label="&mp3tunes.pref.on-send.video;" value="video"/>
<menuitem label="&mp3tunes.pref.on-send.audio;" value="audio"/>
<menuitem label="&mp3tunes.pref.on-send.ask;" value="ask"/>
</menupopup>
</menulist>
</hbox>
</row>
</rows>
</grid>
<spacer flex="1"/>
<hbox>
<button anonid="xCreateBut" label="&mp3tunes.pref.create-account;" oncommand="this.parentNode.parentNode.parentNode.createAccount()"/>
<button anonid="xUpgradeBut" label="&mp3tunes.pref.upgrade-account;" oncommand="this.parentNode.parentNode.parentNode.upgradeAccount()" hidden="true"/>
<button anonid="xOpenLockerBut" label="&mp3tunes.label.open-locker;" oncommand="this.parentNode.parentNode.parentNode.openLocker()" hidden="true"/>
<spacer flex="1"/>
<button label="&mp3tunes.pref.check-account;" oncommand="this.parentNode.parentNode.parentNode.checkAccount()"/>
</hbox>
<spacer flex="1"/>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.mtMgr=Components.classes["@downloadhelper.net/mp3tunes-manager;1"]
.getService(Components.interfaces.dhIMP3Tunes);
this.setAttribute("onsyncfrompreference","this.onSyncFromPreference(event)");
this.setAttribute("onsynctopreference","this.onSyncToPreference(event)");
var prefService=Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
this.pref=prefService.getBranch("dwhelper.mp3tunes.");
setTimeout(function(_this) { _this.updateStatus(); },0,this);
]]>
</constructor>
<method name="init">
<body>
<![CDATA[
]]>
</body>
</method>
<method name="onSyncFromPreference">
<parameter name="event"/>
<body>
<![CDATA[
this.xUsername.value=this.pref.getCharPref("username");
setTimeout(function(_this) {
var password=_this.util.getPassword("mp3tunes");
_this.xPassword.value=(password!=null)?password:"";
},0,this);
this.xPhonenumber.value=this.pref.getCharPref("phonenumber");
this.xOnMobile.value=this.pref.getCharPref("upload.mobile");
this.xOnLocker.value=this.pref.getCharPref("upload.locker");
]]>
</body>
</method>
<method name="onSyncToPreference">
<parameter name="event"/>
<body>
<![CDATA[
this.pref.setCharPref("username",this.xUsername.value);
if(this.xPassword.valueSet)
this.util.setPassword("mp3tunes",this.xPassword.value);
this.pref.setCharPref("phonenumber",this.xPhonenumber.value);
this.pref.setCharPref("upload.mobile",this.xOnMobile.value);
this.pref.setCharPref("upload.locker",this.xOnLocker.value);
]]>
</body>
</method>
<method name="createAccount">
<body>
<![CDATA[
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var w = wm.getMostRecentWindow("navigator:browser");
var data={};
w.openDialog("chrome://dwhelper/content/mp3tunes/create-account.xul",
"mp3tunes-create-account",
"chrome,centerscreen,modal,resizable=yes",data);
if(data.accountData) {
this.xUsername.value=data.accountData.username;
this.xPassword.value=data.accountData.password;
this.updateStatus();
this.util.alertWarning(this.util.getText("mp3tunes.message.account-created"));
}
]]>
</body>
</method>
<method name="upgradeAccount">
<body>
<![CDATA[
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var w = wm.getMostRecentWindow("navigator:browser");
w.open("http://www.downloadhelper.net/mp3tunes-upgrade.php");
]]>
</body>
</method>
<method name="checkAccount">
<body>
<![CDATA[
function AccountStatusObserver(client) {
this.client=client;
}
AccountStatusObserver.prototype={
observe: function(subject,topic,data) {
if(topic=="mp3tunes-account-status") {
this.client.updateStatus();
}
}
}
try {
while(this.xStatus.firstChild)
this.xStatus.removeChild(this.xStatus.firstChild);
this.xStatus.appendChild(document.createTextNode(this.util.getText("mp3tunes.text.checking-account")));
this.disableAll(true);
this.mtMgr.accountStatus(
this.xUsername.value,
this.xPassword.value,
new AccountStatusObserver(this)
);
} catch(e) {
}
]]>
</body>
</method>
<method name="updateStatus">
<body>
<![CDATA[
this.disableAll(false);
var status="unchecked";
try {
status=this.pref.getCharPref("last-status");
} catch(e) {}
this.xStatusRow.setAttribute("hidden","true");
var lastStatusText=null;
switch(status) {
case "unchecked":
this.xCreateBut.setAttribute("hidden","false");
this.xUpgradeBut.setAttribute("hidden","true");
this.xOpenLockerBut.setAttribute("hidden","true");
break;
case "free":
this.xCreateBut.setAttribute("hidden","true");
this.xUpgradeBut.setAttribute("hidden","false");
this.xOpenLockerBut.setAttribute("hidden","false");
lastStatusText=this.util.getText("mp3tunes.message.free-account-verified");
break;
case "premium":
this.xCreateBut.setAttribute("hidden","true");
this.xUpgradeBut.setAttribute("hidden","true");
this.xOpenLockerBut.setAttribute("hidden","false");
lastStatusText=this.util.getText("mp3tunes.message.premium-account-verified");
break;
default:
this.xCreateBut.setAttribute("hidden","false");
this.xUpgradeBut.setAttribute("hidden","true");
this.xOpenLockerBut.setAttribute("hidden","true");
lastStatusText=status;
}
if(lastStatusText) {
while(this.xStatus.firstChild)
this.xStatus.removeChild(this.xStatus.firstChild);
this.xStatus.appendChild(document.createTextNode(lastStatusText));
this.xStatusRow.setAttribute("hidden","false");
}
]]>
</body>
</method>
<method name="disableAll">
<parameter name="disable"/>
<body>
<![CDATA[
var tbs=["xUsername","xPassword","xPhonenumber"];
for(var i in tbs) {
this[tbs[i]].disabled=disable;
}
]]>
</body>
</method>
<method name="privacyPolicy">
<body>
<![CDATA[
window.open("http://www.mp3tunes.com/privacy?partner=5418414535");
]]>
</body>
</method>
<method name="openLocker">
<body>
<![CDATA[
function AuthObserver(client) {
this.client=client;
}
AuthObserver.prototype={
observe: function(subject,topic,data) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var window = wm.getMostRecentWindow("navigator:browser");
if(topic=="mp3tunes-auth-succeeded") {
window.open("http://www.mp3tunes.com/player/");
} else {
this.client.util.alertError(this.client.util.getText("mp3tunes.error.no-login-check-credentials"));
}
}
}
this.mtMgr.authenticate(this.xUsername.value,this.xPassword.value,new AuthObserver(this));
]]>
</body>
</method>
</implementation>
</binding>
<binding id="MP3TunesCreateAccount" extends="../widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<grid flex="1">
<columns>
<column/>
<column/>
</columns>
<rows>
<row align="center">
<label value="&mp3tunes.pref.username;"/>
<textbox anonid="xUsername"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.password;"/>
<textbox anonid="xPassword" type="password"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.password-repeat;"/>
<textbox anonid="xPassword2" type="password"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.firstname;"/>
<textbox anonid="xFirstname"/>
</row>
<row align="center">
<label value="&mp3tunes.pref.lastname;"/>
<textbox anonid="xLastname"/>
</row>
</rows>
</grid>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
if(this.hasAttribute("dialog"))
this.dialog=document.getElementById(this.getAttribute("dialog"));
this.mtMgr=Components.classes["@downloadhelper.net/mp3tunes-manager;1"]
.getService(Components.interfaces.dhIMP3Tunes);
]]>
</constructor>
<destructor>
<![CDATA[
]]>
</destructor>
<method name="validate">
<body>
<![CDATA[
if(!/^[0-9a-zA-Z][-.\w]*[0-9a-zA-Z]*@[0-9a-zA-Z][-\w][^_]*[0-9a-zA-Z]\.+[a-zA-Z]{2,9}$/.test(this.xUsername.value)) {
this.util.alertError(this.util.getText("mp3tunes.error.username-invalid"));
this.selectField(this.xUsername);
return null;
}
if(this.xPassword.value!=this.xPassword2.value) {
this.util.alertError(this.util.getText("mp3tunes.error.unmatching-passwords"));
this.selectField(this.xPassword);
return null;
}
if(this.xPassword.value.length==0) {
this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
this.selectField(this.xPassword);
return null;
}
if(this.xFirstname.value.length==0) {
this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
this.selectField(this.xFirstname);
return null;
}
if(this.xLastname.value.length==0) {
this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
this.selectField(this.xLastname);
return null;
}
this.disableAll(true);
function CreateAccountObserver(client) {
this.client=client;
}
CreateAccountObserver.prototype={
observe: function(subject,topic,data) {
if(topic=="mp3tunes-create-account-succeeded") {
this.client.serverResponse(true,null);
}
if(topic=="mp3tunes-create-account-failed") {
this.client.serverResponse(false,data);
}
}
}
try {
this.mtMgr.createAccount(
this.xUsername.value,
this.xPassword.value,
this.xFirstname.value,
this.xLastname.value,
new CreateAccountObserver(this)
);
} catch(e) {
}
]]>
</body>
</method>
<method name="selectField">
<parameter name="field"/>
<body>
<![CDATA[
field.focus();
field.select();
]]>
</body>
</method>
<method name="disableAll">
<parameter name="disable"/>
<body>
<![CDATA[
if(this.dialog) {
this.dialog.getButton("accept").setAttribute("hidden",""+disable);
this.dialog.getButton("cancel").setAttribute("hidden",""+disable);
}
var tbs=["xUsername","xPassword","xPassword2","xFirstname","xLastname"];
for(var i in tbs) {
this[tbs[i]].disabled=disable;
}
]]>
</body>
</method>
<method name="serverResponse">
<parameter name="status"/>
<parameter name="message"/>
<body>
<![CDATA[
this.disableAll(false);
if(!status) {
this.util.alertError(message);
} else {
if(this.getAttribute("oncreatedaccount")) {
try {
var f=new Function("data",this.getAttribute("oncreatedaccount"));
f.call(this,{
username: this.xUsername.value,
password: this.xPassword.value,
firstname: this.xFirstname.value,
lastname: this.xLastname
});
} catch(e) {
}
}
}
]]>
</body>
</method>
</implementation>
<handlers>
<!--
<handler event="DOMAttrModified">
<![CDATA[
]]>
</handler>
-->
</handlers>
</binding>
<binding id="MP3TunesTitle" extends="../widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&mp3tunes.title.artist-name;" class="mandatory"/>
<textbox anonid="xArtistName"/>
</row>
<row align="center">
<label value="&mp3tunes.title.album-title;"/>
<textbox anonid="xAlbumTitle"/>
</row>
<row align="center">
<label value="&mp3tunes.title.track-title;" class="mandatory"/>
<textbox anonid="xTrackTitle"/>
</row>
<row align="center">
<label value="&mp3tunes.title.track-number;"/>
<hbox align="center">
<textbox anonid="xTrackNumber"/>
<spacer flex="1"/>
<label value="&mp3tunes.title.year;"/>
<textbox anonid="xYear"/>
</hbox>
</row>
</rows>
</grid>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
]]>
</constructor>
<destructor>
<![CDATA[
]]>
</destructor>
<method name="validate">
<parameter name="entry"/>
<body>
<![CDATA[
if(this.xArtistName.value.length==0) {
this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
this.selectField(this.xArtistName);
return false;
}
if(this.xTrackTitle.value.length==0) {
this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
this.selectField(this.xTrackTitle);
return false;
}
this.util.setPropsString(entry,"mp3tunes-artist-name",this.xArtistName.value);
this.util.setPropsString(entry,"mp3tunes-album-title",this.xAlbumTitle.value);
this.util.setPropsString(entry,"mp3tunes-track-title",this.xTrackTitle.value);
this.util.setPropsString(entry,"mp3tunes-track-number",this.xTrackNumber.value);
this.util.setPropsString(entry,"mp3tunes-year",this.xYear.value);
return true;
]]>
</body>
</method>
<method name="selectField">
<parameter name="field"/>
<body>
<![CDATA[
field.focus();
field.select();
]]>
</body>
</method>
</implementation>
<handlers>
<!--
<handler event="DOMAttrModified">
<![CDATA[
]]>
</handler>
-->
</handlers>
</binding>
</bindings>